<template>
	<view class="content">
		  <view class="data">
			  <view class="item" @click="goPage(item.id)" v-for="item in students">{{item.studentName}}</view>
		  </view>
	</view>
</template>

<script>
	import $util from '../../../utils/util.js'
	export default {
		data() {
			return {
				students: []
			}
		},
		
		mounted() {
			this.getChild();
		},
		
		methods: {
			getChild(){
				let parent = uni.getStorageSync('parent');
				uni.request({
					url: this.websiteUrl + 'app/chooseStudent',
					data:{
						parentId: parent.id
					},
					success: (res) => {
						if (res.data.code == 0) {
							this.students = res.data.studentEntityList;
							if(this.students.length == 1){
								let student = this.students[0];
								//跳转到个人中心
								uni.navigateTo({
									url: '/pages/my/child/child?bid='+this.$util.getUrlCode("bid")+'&id='+student.id
								}) 
							}
						}
					}
				});
			},
			
			goPage(id){
				//跳转到个人中心
				uni.navigateTo({
					url: '/pages/my/child/child?bid='+this.$util.getUrlCode("bid")+'&id='+id
				}) 
			}
		}
	}
</script>

<style lang="scss">
.content{
	height:100%;
	background: #F8F9F9;
}
.data{
	padding-top: 2*$lg-interval;
	.item{
		text-align: center;
		line-height: 100rpx;
		background: #FFFFFF;
		box-shadow: 0px 0px 12rpx 4rpx rgba(186, 196, 207, 0.22);
		border-radius: 16rpx;
		margin-bottom: $lg-interval;
		font-size: $font-size-lg;
		font-weight: 500
	}
}
</style>
